package cn.calm.j2se.jpa.entity;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;


/**
 * The persistent class for the student database table.
 * 
 */
@Entity
@Table(name="STUDENT")
public class Student implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(unique=true, nullable=false)
	private int id;

	private int age;

	@Column(length=255)
	private String name;

	//bi-directional many-to-many association to Teacher
    @ManyToMany
	@JoinTable(
		name="student_teacher"
		, joinColumns={
			@JoinColumn(name="STUDENT_ID", nullable=false)
			}
		, inverseJoinColumns={
			@JoinColumn(name="TEACHER_ID", nullable=false)
			}
		)
	private Set<Teacher> teachers;

    public Student() {
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getAge() {
		return this.age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<Teacher> getTeachers() {
		return this.teachers;
	}

	public void setTeachers(Set<Teacher> teachers) {
		this.teachers = teachers;
	}
	
}